home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_amanda.idb / usr / freeware / bin / amcleanup.z / amcleanup
Encoding:
Text File  |  1999-07-16  |  3.0 KB  |  109 lines

  1. #!/bin/sh
  2. #
  3. # Amanda, The Advanced Maryland Automatic Network Disk Archiver
  4. # Copyright (c) 1991-1998 University of Maryland at College Park
  5. # All Rights Reserved.
  6. #
  7. # Permission to use, copy, modify, distribute, and sell this software and its
  8. # documentation for any purpose is hereby granted without fee, provided that
  9. # the above copyright notice appear in all copies and that both that
  10. # copyright notice and this permission notice appear in supporting
  11. # documentation, and that the name of U.M. not be used in advertising or
  12. # publicity pertaining to distribution of the software without specific,
  13. # written prior permission.  U.M. makes no representations about the
  14. # suitability of this software for any purpose.  It is provided "as is"
  15. # without express or implied warranty.
  16. #
  17. # U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
  19. # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21. # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  22. # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23. #
  24. # Author: James da Silva, Systems Design and Analysis Group
  25. #               Computer Science Department
  26. #               University of Maryland at College Park
  27. #
  28.  
  29. #
  30. # amcleanup.sh - clean up and generate a report after a crash.
  31.  
  32. # try to hit all the possibilities here
  33. prefix=/usr/freeware
  34. exec_prefix=${prefix}
  35. libexecdir=/usr/freeware/libexec
  36. sbindir=/usr/freeware/bin
  37.  
  38. confdir=/usr/freeware/etc/amanda
  39.  
  40. PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb
  41. export PATH
  42.  
  43. USE_VERSION_SUFFIXES="no"
  44. if test "$USE_VERSION_SUFFIXES" = yes; then
  45.     SUF=-2.4.1p1
  46. else
  47.     SUF=
  48. fi
  49.  
  50. if [ $# -ne 1 ]
  51. then
  52.         echo "Usage: amcleanup conf"
  53.         exit 1
  54. fi
  55.  
  56. conf=$1
  57. if [ ! -d $confdir/$conf ]; then
  58.         echo "amcleanup: could not cd into $confdir/$conf"
  59.         exit 1
  60. fi
  61.  
  62. cd $confdir/$conf
  63.  
  64. logdir=`getconf$SUF logdir`
  65. logfile=$logdir/log
  66. errfile=$logdir/amdump
  67. tapecycle=`getconf$SUF tapecycle`
  68.  
  69. if [ -f $logfile ]; then
  70.     lognotfound=0
  71.  
  72.     echo "amcleanup: processing outstanding log file."
  73.     exec </dev/null >/dev/null 2>&1
  74.     amreport$SUF
  75.  
  76.     # Trim the index file to those for dumps that still exist.
  77.     amtrmidx$SUF $conf
  78.  
  79. else
  80.     echo "amcleanup: no unprocessed logfile to clean up."
  81.  
  82.     lognotfound=1
  83. fi
  84.  
  85. if [ -f $errfile ]; then
  86.     # if log was found, this will have been directed to /dev/null,
  87.     # which is fine.
  88.     echo "amcleanup: $errfile exists, renaming it."
  89.  
  90.     # Keep debug log through the tapecycle plus a couple days
  91.     maxdays=`expr $tapecycle + 2`
  92.  
  93.     days=1
  94.     # First, find out the last existing errfile,
  95.     # to avoid ``infinite'' loops if tapecycle is infinite
  96.     while [ $days -lt $maxdays ] && [ -f $errfile.$days ]; do
  97.     days=`expr $days + 1`
  98.     done
  99.     # Now, renumber the existing log files
  100.     while [ $days -ge 2 ]; do
  101.     ndays=`expr $days - 1`
  102.     mv $errfile.$ndays $errfile.$days
  103.     days=$ndays
  104.     done
  105.     mv $errfile $errfile.1
  106. fi
  107.     
  108. exit $lognotfound
  109.